
#include "desk_root.h"


static desk_root_t  root_para;

static void desk_root_timer_callback(lv_timer_t* t)
{
	




}


static void desk_root_key_event_cb(lv_event_t* e)
{
	uint32_t  key   = 0;
	int32_t  index  = 0;
	
	key = lv_event_get_key(e);

	
	
}



int32_t desk_root_ui_create(void)
{



	root_para.root_obj = lv_obj_create(lv_scr_act());
	lv_obj_set_style_radius(root_para.root_obj, 0, LV_PART_MAIN);
	lv_obj_set_style_border_width(root_para.root_obj, 0, LV_PART_MAIN);
	lv_obj_set_style_border_color(root_para.root_obj, lv_color_make(0x00, 0x00, 0x00), LV_PART_MAIN);
	lv_obj_set_style_border_opa(root_para.root_obj, LV_OPA_0, LV_PART_MAIN);

	lv_obj_set_style_outline_width(root_para.root_obj, 0, LV_PART_MAIN);
	lv_obj_set_style_shadow_width(root_para.root_obj, 0, LV_PART_MAIN);
	lv_obj_set_scrollbar_mode(root_para.root_obj, LV_SCROLLBAR_MODE_OFF);
	
#if 0
	lv_obj_set_style_bg_opa(root_para.root_obj, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(root_para.root_obj, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(root_para.root_obj, lv_color_make(0xFF, 0x00, 0x00), LV_PART_MAIN);
#endif
	
	lv_obj_set_size(root_para.root_obj, 1024, 600);
	lv_obj_set_pos(root_para.root_obj, 0, 0);
	
	lv_obj_add_event_cb(root_para.root_obj, desk_root_key_event_cb, LV_EVENT_KEY,NULL);


#if 0
	root_para.root_group = lv_group_create();
	if(root_para.root_group){
		lv_indev_set_group(lv_get_indev(), root_para.root_group);
		lv_group_remove_all_objs(root_para.root_group);
		lv_group_add_obj(root_para.root_group,root_para.root_obj);
	}
#endif


	return 0;
}

int32_t desk_root_ui_delete(void)
{
	if(root_para.root_group){
		lv_group_remove_all_objs(root_para.root_group);
		lv_group_del(root_para.root_group);
		root_para.root_group = NULL;
	}
	
	if(root_para.root_obj){
		lv_obj_del(root_para.root_obj);
		root_para.root_obj = NULL;
	}

	return 0;
}

int32_t desk_root_create(void)
{
	memset(&root_para, 0,sizeof(desk_root_t));

	root_para.root_timer = NULL;   
	root_para.root_obj   = NULL; 
	root_para.root_group = NULL;
	
	desk_root_ui_create();
	
	if(!root_para.root_timer)
		root_para.root_timer = lv_timer_create(desk_root_timer_callback, 1*1000, 0);	
	
	
	return 0;
}


int32_t desk_root_delete(void)
{
	
	if(root_para.root_timer){
		lv_timer_del(root_para.root_timer);
		root_para.root_timer = NULL;
	}
	
	desk_root_ui_delete();

	return 0;
}



